<template>
  <div >
    <el-table
      :data="tableData"
      style="width: 100%"
      :default-sort = "{prop: 'date', order: 'descending'}"
    >
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="手机号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="时间"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      align="right"
      :total="totals"
      :page-size="pageSize"
      :current-page="currentPage"
      @prev-click="shang"
      @next-click="xia"
      @current-change="goto">
    >

    </el-pagination>
  </div>
</template>


<script>
import axios from "axios";
export default {

  data () {
    return {
      pageSize:10,
      currentPage:1,
      totals:0,
      tableData: []
    }
  },
  methods: {
    formatter(row, column) {
      return row.address;
    },
    shang(s){
      this.currentPage=s
      this.page()
    },
    xia(x){
      this.currentPage=x
      this.page()
    },
    goto(g){
      this.currentPage=g
      this.page()
    },
    page(){
      axios.post("/user/list",{"currentPage":this.currentPage,"pageSize":this.pageSize})
        .then(result=>{
          this.totals=result.data.totals
          this.tableData=result.data.rows
        })
        .catch(result=>{
          alert("异常")
        })
    }
  },
  mounted() {
    this.page()
  }
}
</script>
